//
//  GuideViewController.m
//  ZhiHuiLiJiang
//
//  Created by Work on 2018/11/12.
//  Copyright © 2018年 王雅鹏. All rights reserved.
//导览VC

#import "GuideViewController.h"
#import "ChooseTypeView.h"//身份选择的View
#import "GuideSearchView.h"//搜索框View
#import "LLSearchViewController.h"//搜索VC
#import "BYHomeTopCarouselModel.h"//轮播图model
#import "BYTableViewCell.h"//导览页tabviewcell
#import "BYcitizenModel.h"//导览页tabviewcell的model
#import "GuideHeardView.h"//导览页tabviewHeadView-热门景点-玩法路线
#import "GuiBenDiTwoView.h"//导览页tabviewHeadView-内容精选
#import "BYFootView.h"//导览页tabviewFootView

@interface GuideViewController ()<UITableViewDelegate,UITableViewDataSource,GuideHeardViewDelegate,GuiBenDiTwoViewViewDelegate,GuideSearchViewDelegate>
/**身份选择的View*/
@property (nonatomic ,strong) ChooseTypeView *chooseView;
/**搜索框View*/
@property (nonatomic ,strong) GuideSearchView * searchView;
/**tableView*/
@property (nonatomic ,strong) UITableView * mainTableView;
/**轮播图参数*/
@property(nonatomic,copy)NSString *carouselIconsStr;
/**轮播图数组*/
@property(nonatomic,strong)NSMutableArray *topCarDataArr;
/**玩法路线参数*/
@property(nonatomic,copy)NSString *dictCountTwo;
/**玩法路线的数组*/
@property(nonatomic,strong)NSMutableArray *hotDataArr;
/**新闻资讯 内容精选参数*/
@property(nonatomic,copy)NSString *dictCountOne;
/**新闻资讯 内容精选的数组*/
@property(nonatomic,strong)NSMutableArray *citizenDataArr;
/**热门景点参数*/
@property(nonatomic,copy)NSString *dictCounthree;
/**市民热议参数*/
@property(nonatomic,copy)NSString *dictCounfour;
/**热门景点 市民热议的数组*/
@property(nonatomic,strong)NSMutableArray *topicHotDataArr;
/**暂废*/
@property(nonatomic,strong)NSMutableArray *topicListDataArr;

@end
@implementation GuideViewController
#pragma mark- init初始化
- (void)viewDidLoad {
    [super viewDidLoad];
    NSUserDefaults *useDef = [NSUserDefaults standardUserDefaults];
    if (![useDef boolForKey:@"GuidenotFirst"]) {// 如果是第一次进入引导页
        [self addInitChooseView];//选择身份的View
    }else{// 否则直接进入应用
        [self.view addSubview:self.searchView];
        [self.view addSubview:self.mainTableView];
        [self creatArray];
    }
    self.view.backgroundColor = [UIColor whiteColor];
}
-(void)viewWillAppear:(BOOL)animated{
    NSUserDefaults *useDef = [NSUserDefaults standardUserDefaults];
    if (![useDef boolForKey:@"GuidenotFirst"]) {// 如果是第一次进入引导页
        self.tabBarController.tabBar.hidden = YES;
        self.navigationController.navigationBarHidden=YES;
    }else{// 否则直接进入应用
        self.navigationController.navigationBarHidden=YES;
        if (self.tabBarController.tabBar.isHidden) {
            self.tabBarController.tabBar.hidden = NO;
        }
    }
    [self loadGuideData];
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    self.navigationController.navigationBarHidden=NO;
}
- (void)addInitChooseView{//选择身份的View
    _chooseView = [[ChooseTypeView alloc]initWithFrame:CGRectMake(0, BY_StatusBar_H, BY_ScreenWidth, BY_ScreenHeight-BY_StatusBar_H)];
    _chooseView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:_chooseView];
    BY_kWeakSelf(ws);
    _chooseView.clickCompleteBtn = ^(NSString *typeStr) {
        [ws comfirmBtnClick:typeStr];
    };
}
- (GuideSearchView *)searchView{//搜索框
    if (!_searchView) {
        _searchView = [[GuideSearchView alloc]initWithFrame:CGRectMake(0, 0, KSCREEWIDTH, BY_Nav_H+BY_Height(20)) with:@"1"];
        _searchView.delegate = self;
        _searchView.backgroundColor = [UIColor whiteColor];
    }
    return _searchView;
}
- (UITableView *)mainTableView{//tableView
    if (!_mainTableView) {
        _mainTableView  =[[UITableView alloc]initWithFrame:CGRectMake(0, BY_Nav_H+BY_Height(20), KSCREEWIDTH, KSCREEHEGIHT -BY_NavBot_H-BY_Height(20)-49) style:UITableViewStyleGrouped];
        _mainTableView.delegate =self;
        _mainTableView.separatorStyle = NO;
        _mainTableView.dataSource = self;
        _mainTableView.tableFooterView = [UIView new];
        [_mainTableView registerClass:[BYTableViewCell class] forCellReuseIdentifier:@"BYTableViewCell"];
        _mainTableView.tableHeaderView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 1)];
        _mainTableView.tableFooterView=[[BYFootView alloc]initWithFrame:CGRectMake(0, 0, KSCREEWIDTH, 40)];
    }
    return _mainTableView;
}

#pragma mark- tableView代理
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if ([APPDELEGATE.loginInfoDic[@"status_type"] isEqualToString:@"stu"]) {
        if (section == 0) {
            return _hotDataArr.count;
        }else{
            return _citizenDataArr.count;
        }
    }else{
        return _citizenDataArr.count;
    }
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    if ([APPDELEGATE.loginInfoDic[@"status_type"] isEqualToString:@"stu"]) {
        return 2;
    }else{
        return 1;
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if ([APPDELEGATE.loginInfoDic[@"status_type"] isEqualToString:@"stu"]) {
        if (section == 0) {
            return 302;
        }else{
            return 20;
        }
    }else{
        return 302;
    }
    return 302;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if ([APPDELEGATE.loginInfoDic[@"status_type"] isEqualToString:@"stu"]) {//游客
        if (indexPath.section == 0) {
            BYTableViewCell  *cell = [tableView dequeueReusableCellWithIdentifier:@"BYTableViewCell" forIndexPath:indexPath];
            if (self.hotDataArr.count!=0) {
                BYcitizenModel *model = self.hotDataArr[indexPath.row];
                [cell setBYcitizenModel:model];
            }
            return cell;
        }else{
            BYTableViewCell  *cell = [tableView dequeueReusableCellWithIdentifier:@"BYTableViewCell" forIndexPath:indexPath];
            if (self.citizenDataArr.count!=0) {
                BYcitizenModel *model = self.citizenDataArr[indexPath.row];
                [cell setBYcitizenModel:model];
            }
            return cell;
        }
    }else{
        BYTableViewCell  *cell = [tableView dequeueReusableCellWithIdentifier:@"BYTableViewCell" forIndexPath:indexPath];
        if (self.citizenDataArr.count!=0) {
            BYcitizenModel *model = self.citizenDataArr[indexPath.row];
            [cell setBYcitizenModel:model];
        }
        return cell;
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return BY_Width(164) + BY_Height(40);
}
- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    if ([APPDELEGATE.loginInfoDic[@"status_type"] isEqualToString:@"stu"]) {//游客
        if (section ==0) {
            GuideHeardView*headV=[tableView dequeueReusableHeaderFooterViewWithIdentifier:@"headv"];
            if (!headV) {
                headV=[[GuideHeardView alloc]initWithReuseIdentifier:@"headv"];
                headV.delegate = self;
            }
            BY_kWeakSelf(ws);
            //            headV.VScorll.titlesGroup = @[@"1121",@"111111"];
            headV.HMdelarray = self.topCarDataArr;
            headV.clickRotationIconView = ^(NSInteger index) {
                [ws cycleScrollViewIconClick:index];
            };
            if (self.topicHotDataArr!=nil) {
                headV.ImageMdelarray = self.topicHotDataArr;
                [headV.collectioneView reloadData];
            }
            headV.twoTitleLabel.text = @"玩法路线";
            headV.titleLabel.text = @"热门景点";
            return headV;
        }else{
            GuiBenDiTwoView*headV=[tableView dequeueReusableHeaderFooterViewWithIdentifier:@"GuiBenDiTwoView"];
            if (!headV) {
                headV=[[GuiBenDiTwoView alloc]initWithReuseIdentifier:@"GuiBenDiTwoView"];
                headV.delegate = self;
            }
            if (section == 2) {
                headV.titleLabel.text = @"内容精选";
            }else{
                headV.titleLabel.text = @"内容精选";
            }
            return headV;
        }
    }else{
        GuideHeardView*headV=[tableView dequeueReusableHeaderFooterViewWithIdentifier:@"headv"];
        if (!headV) {
            headV=[[GuideHeardView alloc]initWithReuseIdentifier:@"headv"];
            headV.delegate = self;
        }
        BY_kWeakSelf(ws);
        headV.HMdelarray = self.topCarDataArr;
        headV.clickRotationIconView = ^(NSInteger index) {
            [ws cycleScrollViewIconClick:index];
        };
        NSLog(@"%@",headV.HScorll.imageURLStringsGroup);
        if (self.topicHotDataArr!=nil) {
            headV.ImageMdelarray = self.topicHotDataArr;
            [headV.collectioneView reloadData];
        }
        headV.titleLabel.text = @"市民热议";
        headV.twoTitleLabel.text = @"新闻资讯";
        return headV;
    }
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    if ([APPDELEGATE.loginInfoDic[@"status_type"] isEqualToString:@"stu"]) {//游客
        if (indexPath.section ==0) {//玩法路线详情
            BYcitizenModel *citizenModel = self.hotDataArr[indexPath.row];
            for (BYSetModel *models in APPDELEGATE.SetDataArray) {
                if ([models.setting_name isEqualToString:@"guide-travel-detail"]) {
                    NSString *urlStr = models.setting_value;
                    NSString *paramStr = [NSString stringWithFormat:@"id=%@&userid=%@&token=%@",citizenModel.material_uid,[SaveCacheData loadDataStrWithKey:currentUserudid] ==nil?@"":[SaveCacheData loadDataStrWithKey:currentUserudid],[SaveCacheData loadDataStrWithKey:currentUserToken] ==nil?@"":[SaveCacheData loadDataStrWithKey:currentUserToken]];
                    NSString *webURL= @"";
                    if ([urlStr rangeOfString:@"?"].location == NSNotFound) {//没有?参数
                        webURL = [NSString stringWithFormat:@"%@?%@",urlStr,paramStr];
                    } else {//有参数
                        webURL = [NSString stringWithFormat:@"%@&%@",urlStr,paramStr];
                    }
                    BYWebVC *VC = [[BYWebVC alloc]init];
                    VC.url = webURL;
                    [self.navigationController pushViewController:VC animated:YES];
                }
            }
        }else{
            BYcitizenModel *citizenModel = self.citizenDataArr[indexPath.row];
            for (BYSetModel *models in APPDELEGATE.SetDataArray) {
                if ([models.setting_name isEqualToString:@"guide-info-detail"]) {
                    NSString *urlStr = models.setting_value;
                    NSString *paramStr = [NSString stringWithFormat:@"id=%@&userid=%@&token=%@",citizenModel.material_uid,[SaveCacheData loadDataStrWithKey:currentUserudid] ==nil?@"":[SaveCacheData loadDataStrWithKey:currentUserudid],[SaveCacheData loadDataStrWithKey:currentUserToken] ==nil?@"":[SaveCacheData loadDataStrWithKey:currentUserToken]];
                    NSString *webURL= @"";
                    if ([urlStr rangeOfString:@"?"].location == NSNotFound) {//没有?参数
                        webURL = [NSString stringWithFormat:@"%@?%@",urlStr,paramStr];
                    } else {//有参数
                        webURL = [NSString stringWithFormat:@"%@&%@",urlStr,paramStr];
                    }
                    BYWebVC *VC = [[BYWebVC alloc]init];
                    VC.url = webURL;
                    [self.navigationController pushViewController:VC animated:YES];
                }
            }
        }
    }else{
        BYcitizenModel *citizenModel = self.citizenDataArr[indexPath.row];
        for (BYSetModel *models in APPDELEGATE.SetDataArray) {
            if ([models.setting_name isEqualToString:@"guide-info-detail"]) {
                NSString *urlStr = models.setting_value;
                NSString *paramStr = [NSString stringWithFormat:@"id=%@&userid=%@&token=%@",citizenModel.material_uid,[SaveCacheData loadDataStrWithKey:currentUserudid] ==nil?@"":[SaveCacheData loadDataStrWithKey:currentUserudid],[SaveCacheData loadDataStrWithKey:currentUserToken] ==nil?@"":[SaveCacheData loadDataStrWithKey:currentUserToken]];
                NSString *webURL= @"";
                if ([urlStr rangeOfString:@"?"].location == NSNotFound) {//没有?参数
                    webURL = [NSString stringWithFormat:@"%@?%@",urlStr,paramStr];
                } else {//有参数
                    webURL = [NSString stringWithFormat:@"%@&%@",urlStr,paramStr];
                }
                BYWebVC *VC = [[BYWebVC alloc]init];
                VC.url = webURL;
                [self.navigationController pushViewController:VC animated:YES];
            }
        }
    }
}

#pragma mark- 数据处理
- (void)creatArray{//玩法路线的数组
    self.hotDataArr = [[NSMutableArray alloc]init];
}

#pragma mark- 用户交互
- (void)comfirmBtnClick:(NSString *)type{//选中了身份
    [APPDELEGATE.loginInfoDic setObject:type forKey:@"status_type"];
    [[NSUserDefaults standardUserDefaults] setObject:APPDELEGATE.loginInfoDic forKey:LoginUserName];
    [[NSUserDefaults standardUserDefaults] synchronize];
    NSUserDefaults *useDef = [NSUserDefaults standardUserDefaults];
    [useDef setBool:YES forKey:@"GuidenotFirst"];
    [useDef synchronize];

    self.tabBarController.tabBar.hidden = NO;
    [self.chooseView removeFromSuperview];
    [self.view addSubview:self.searchView];
    [self.view addSubview:self.mainTableView];
    [self creatArray];
    [self loadGuideData];
}
- (void)screachClick{//点击了搜索框
    LLSearchViewController *VC = [[LLSearchViewController alloc]init];
    [self.navigationController pushViewController:VC animated:YES];
}
- (void)cycleScrollViewIconClick:(NSInteger)index{//点击了轮播图
    NSLog(@"点击了轮播图：%tu",index);
    if (_topCarDataArr.count > 0) {
        BYHomeTopCarouselModel *topCarModel = _topCarDataArr[index];
        if (topCarModel.carousel_type == 0) {//直接跳转
            BYWebVC *webVC = [[BYWebVC alloc]init];
            webVC.url = topCarModel.url;//@"http://www.tianhuicity.com/m";
            webVC.titleStr = topCarModel.carousel_title;//@"商业";
            [self.navigationController pushViewController:webVC animated:YES];
        }else if (topCarModel.carousel_type == 1){//验证跳转,打开第三方app
            NSLog(@"需要验证，然后跳转到第三方app");
        }else if (topCarModel.carousel_type == 2){//主app内部
            NSLog(@"跳转到主app内部");
        }else{
            NSLog(@"未知的跳转类型");
        }
    }
}

#pragma mark- 其他代理方法
-(void)typeClick{//点击了身份的切换按钮
    if ([APPDELEGATE.loginInfoDic[@"status_type"] isEqualToString:@"stu"]) {
        [APPDELEGATE.loginInfoDic setObject:@"tea" forKey:@"status_type"];
        [[NSUserDefaults standardUserDefaults] setObject:APPDELEGATE.loginInfoDic forKey:LoginUserName];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }else{
        [APPDELEGATE.loginInfoDic setObject:@"stu" forKey:@"status_type"];
        [[NSUserDefaults standardUserDefaults] setObject:APPDELEGATE.loginInfoDic forKey:LoginUserName];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
    [self loadGuideData];
}
-(void)tapImage:(NSString *)str{//点击了市民热议or热门景点下面的左右滚动图
    for (BYSetModel *models in APPDELEGATE.SetDataArray) {
        if ([models.setting_name isEqualToString:@"guide-travel-detail"]) {
            NSString *urlStr = models.setting_value;
            NSString *paramStr = [NSString stringWithFormat:@"id=%@&userid=%@&token=%@",str,[SaveCacheData loadDataStrWithKey:currentUserudid] ==nil?@"":[SaveCacheData loadDataStrWithKey:currentUserudid],[SaveCacheData loadDataStrWithKey:currentUserToken] ==nil?@"":[SaveCacheData loadDataStrWithKey:currentUserToken]];
            NSString *webURL= @"";
            if ([urlStr rangeOfString:@"?"].location == NSNotFound) {//没有?参数
                webURL = [NSString stringWithFormat:@"%@?%@",urlStr,paramStr];
            } else {//有参数
                webURL = [NSString stringWithFormat:@"%@&%@",urlStr,paramStr];
            }
            BYWebVC *VC = [[BYWebVC alloc]init];
            VC.url = webURL;
            [self.navigationController pushViewController:VC animated:YES];
        }
    }
}
-(void)twomoreBtn{
    if ([APPDELEGATE.loginInfoDic[@"status_type"] isEqualToString:@"stu"]) {//玩法路线-查看更多
        for (BYSetModel *models in APPDELEGATE.SetDataArray) {
            if ([models.setting_name isEqualToString:@"guide-travel-list"]) {
                NSString *urlStr = models.setting_value;
                NSString *paramStr = [NSString stringWithFormat:@"userid=%@&token=%@",[SaveCacheData loadDataStrWithKey:currentUserudid] ==nil?@"":[SaveCacheData loadDataStrWithKey:currentUserudid],[SaveCacheData loadDataStrWithKey:currentUserToken] ==nil?@"":[SaveCacheData loadDataStrWithKey:currentUserToken]];
                NSString *webURL= @"";
                if ([urlStr rangeOfString:@"?"].location == NSNotFound) {//没有?参数
                    webURL = [NSString stringWithFormat:@"%@?%@",urlStr,paramStr];
                } else {//有参数
                    webURL = [NSString stringWithFormat:@"%@&%@",urlStr,paramStr];
                }
                BYWebVC *VC = [[BYWebVC alloc]init];
                VC.url = webURL;
                [self.navigationController pushViewController:VC animated:YES];
            }
        }
    }else{
        for (BYSetModel *models in APPDELEGATE.SetDataArray) {//新闻资讯查看更多
            if ([models.setting_name isEqualToString:@"guide-citizenInfo-list"]) {
                NSString *urlStr = models.setting_value;
                NSString *paramStr = [NSString stringWithFormat:@"userid=%@&token=%@",[SaveCacheData loadDataStrWithKey:currentUserudid] ==nil?@"":[SaveCacheData loadDataStrWithKey:currentUserudid],[SaveCacheData loadDataStrWithKey:currentUserToken] ==nil?@"":[SaveCacheData loadDataStrWithKey:currentUserToken]];
                NSString *webURL= @"";
                if ([urlStr rangeOfString:@"?"].location == NSNotFound) {//没有?参数
                    webURL = [NSString stringWithFormat:@"%@?%@",urlStr,paramStr];
                } else {//有参数
                    webURL = [NSString stringWithFormat:@"%@&%@",urlStr,paramStr];
                }
                BYWebVC *VC = [[BYWebVC alloc]init];
                VC.url = webURL;
                [self.navigationController pushViewController:VC animated:YES];
            }
        }
    }
}
-(void)moreBtn{
    if ([APPDELEGATE.loginInfoDic[@"status_type"] isEqualToString:@"stu"]) {//热门景点-查看更多
        for (BYSetModel *models in APPDELEGATE.SetDataArray) {
            if ([models.setting_name isEqualToString:@"guide-spot-list"]) {
                NSString *urlStr = models.setting_value;
                NSString *paramStr = [NSString stringWithFormat:@"userid=%@&token=%@",[SaveCacheData loadDataStrWithKey:currentUserudid] ==nil?@"":[SaveCacheData loadDataStrWithKey:currentUserudid],[SaveCacheData loadDataStrWithKey:currentUserToken] ==nil?@"":[SaveCacheData loadDataStrWithKey:currentUserToken]];
                NSString *webURL= @"";
                if ([urlStr rangeOfString:@"?"].location == NSNotFound) {//没有?参数
                    webURL = [NSString stringWithFormat:@"%@?%@",urlStr,paramStr];
                } else {//有参数
                    webURL = [NSString stringWithFormat:@"%@&%@",urlStr,paramStr];
                }
                BYWebVC *VC = [[BYWebVC alloc]init];
                VC.url = webURL;
                [self.navigationController pushViewController:VC animated:YES];
            }
        }
    }else{//市民热议-查看更多
        for (BYSetModel *models in APPDELEGATE.SetDataArray) {
            if ([models.setting_name isEqualToString:@"guide-publicHot-list"]) {
                NSString *urlStr = models.setting_value;
                NSString *paramStr = [NSString stringWithFormat:@"userid=%@&token=%@",[SaveCacheData loadDataStrWithKey:currentUserudid] ==nil?@"":[SaveCacheData loadDataStrWithKey:currentUserudid],[SaveCacheData loadDataStrWithKey:currentUserToken] ==nil?@"":[SaveCacheData loadDataStrWithKey:currentUserToken]];
                NSString *webURL= @"";
                if ([urlStr rangeOfString:@"?"].location == NSNotFound) {//没有?参数
                    webURL = [NSString stringWithFormat:@"%@?%@",urlStr,paramStr];
                } else {//有参数
                    webURL = [NSString stringWithFormat:@"%@&%@",urlStr,paramStr];
                }
                BYWebVC *VC = [[BYWebVC alloc]init];
                VC.url = webURL;
                [self.navigationController pushViewController:VC animated:YES];
            }
        }
    }
}
-(void)GuiBenDiTwoViewmoreBtn{//点击了内容精选的查看更多
    for (BYSetModel *models in APPDELEGATE.SetDataArray) {
        if ([models.setting_name isEqualToString:@"guide-info-list"]) {
            NSString *urlStr = models.setting_value;
            NSString *paramStr = [NSString stringWithFormat:@"userid=%@&token=%@",[SaveCacheData loadDataStrWithKey:currentUserudid] ==nil?@"":[SaveCacheData loadDataStrWithKey:currentUserudid],[SaveCacheData loadDataStrWithKey:currentUserToken] ==nil?@"":[SaveCacheData loadDataStrWithKey:currentUserToken]];
            NSString *webURL= @"";
            if ([urlStr rangeOfString:@"?"].location == NSNotFound) {//没有?参数
                webURL = [NSString stringWithFormat:@"%@?%@",urlStr,paramStr];
            } else {//有参数
                webURL = [NSString stringWithFormat:@"%@&%@",urlStr,paramStr];
            }
            BYWebVC *VC = [[BYWebVC alloc]init];
            VC.url = webURL;
            [self.navigationController pushViewController:VC animated:YES];
        }
    }
}

#pragma mark- 网络请求
- (void)loadGuideData{//加载导览页数据
    for (BYSetModel *models in APPDELEGATE.SetDataArray) {
        if ([models.setting_name isEqualToString:@"info-selected-size"]) {
            self.dictCountOne = models.setting_value;
        }
        if ([models.setting_name isEqualToString:@"travelguide-hot-size"]) {
            self.dictCountTwo = models.setting_value;
        }
        if ([models.setting_name isEqualToString:@"spot-hot-size"]) {
            self.dictCounthree = models.setting_value;
        }
        if ([models.setting_name isEqualToString:@"info-carousel-size"]) {
            self.dictCounfour = models.setting_value;
        }
        if ([models.setting_name isEqualToString:@"info-carousel-size"]) {
            self.carouselIconsStr = models.setting_value;
        }
    }
    if ([APPDELEGATE.loginInfoDic[@"status_type"] isEqualToString:@"stu"]) {
        NSDictionary *dict1 = @{@"size":BYSafeStr(self.dictCountOne)};
        NSDictionary *dict2 = @{@"size":BYSafeStr(self.dictCounthree)};
        NSDictionary *dict3 = @{@"size":BYSafeStr(self.dictCountTwo)};
        [self getcitizen:dict1];//内容精选
        [self gettopicHot:dict2];//热门景点
        [self gettopicList:dict3];//玩法路线
    }else{
        NSDictionary *dict1 = @{@"page":@"1",@"limit":@"5"};
        NSDictionary *dict2 = @{@"size":BYSafeStr(self.dictCounfour)};
        [self getcitizen:dict1];//新闻资讯
        [self gettopicHot:dict2];//市民热议
    }
    [self getCarouselIcons:BYSafeStr(self.carouselIconsStr)];
    [self.mainTableView reloadData];
}
- (void)getcitizen:(NSDictionary *)dict{//请求内容精选 新闻资讯 的值
    BY_kWeakSelf(ws);
    if ([APPDELEGATE.loginInfoDic[@"status_type"] isEqualToString:@"stu"]) {
        [BYNetworking requestGetOrPostWithType:GET url:LJURL_Visitor_info_selected params:dict success:^(NSInteger code, NSString * _Nonnull msg, id  _Nonnull data) {//内容精选
            NSArray *dataArr = [data objectForKey:@"data"];
            NSMutableArray *dataArrM = [NSMutableArray arrayWithCapacity:dataArr.count];
            for (NSDictionary *dic in dataArr) {
                BYcitizenModel *model = [BYcitizenModel mj_objectWithKeyValues:dic];
                [dataArrM addObject:model];
            }
            ws.citizenDataArr = dataArrM.copy;
            [ws.mainTableView reloadData];
        } fail:^(NSError * _Nonnull error) {
        } showHUD:YES];
    }else{
        [BYNetworking requestGetOrPostWithType:GET url:LJURL_VitizenInfo_citizen params:dict success:^(NSInteger code, NSString * _Nonnull msg, id  _Nonnull data) {//新闻资讯
            NSDictionary *dict = [data objectForKey:@"data"];
            NSArray *dataArr = dict[@"paginator"][@"records"];
            NSMutableArray *dataArrM = [NSMutableArray arrayWithCapacity:dataArr.count];
            for (NSDictionary *dic in dataArr) {
                BYcitizenModel *model = [BYcitizenModel mj_objectWithKeyValues:dic];
                [dataArrM addObject:model];
            }
            ws.citizenDataArr = dataArrM.copy;
            [ws.mainTableView reloadData];
        } fail:^(NSError * _Nonnull error) {
        } showHUD:YES];
    }
}
- (void)gettopicHot:(NSDictionary *)dict{//请求热门景点 市民热议的值
    BY_kWeakSelf(ws);
    if ([APPDELEGATE.loginInfoDic[@"status_type"] isEqualToString:@"stu"]) {
        [BYNetworking requestGetOrPostWithType:GET url:LJURL_Visitor_spot_hot params:dict success:^(NSInteger code, NSString * _Nonnull msg, id  _Nonnull data) {//热门景点
            NSArray *dataArr = [data objectForKey:@"data"];
            NSMutableArray *dataArrM = [NSMutableArray arrayWithCapacity:dataArr.count];
            for (NSDictionary *dic in dataArr) {
                BYcitizenModel *topCarouselModel = [BYcitizenModel mj_objectWithKeyValues:dic];
                [dataArrM addObject:topCarouselModel];
            }
            ws.topicHotDataArr = dataArrM.copy;
            [ws.mainTableView reloadData];
        } fail:^(NSError * _Nonnull error) {
        } showHUD:YES];
    }else{
        [BYNetworking requestGetOrPostWithType:GET url:LJURL_Vitizentopic_hot params:dict success:^(NSInteger code, NSString * _Nonnull msg, id  _Nonnull data) {//市民热议
            NSArray *dataArr = [data objectForKey:@"data"];
            NSMutableArray *dataArrM = [NSMutableArray arrayWithCapacity:dataArr.count];
            for (NSDictionary *dic in dataArr) {
                BYcitizenModel *topCarouselModel = [BYcitizenModel mj_objectWithKeyValues:dic];
                [dataArrM addObject:topCarouselModel];
            }
            ws.topicHotDataArr = dataArrM.copy;
            [ws.mainTableView reloadData];
        } fail:^(NSError * _Nonnull error) {
        } showHUD:YES];
    }
}
- (void)gettopicList:(NSDictionary *)dict{//请求玩法路线的值
    BY_kWeakSelf(ws);
    if ([APPDELEGATE.loginInfoDic[@"status_type"] isEqualToString:@"stu"]) {
        [BYNetworking requestGetOrPostWithType:GET url:LJURL_Visitor_travelguide_hot params:dict success:^(NSInteger code, NSString * _Nonnull msg, id  _Nonnull data) {//玩法路线
            NSArray *dataArr = [data objectForKey:@"data"];
            NSMutableArray *dataArrM = [NSMutableArray arrayWithCapacity:dataArr.count];
            for (NSDictionary *dic in dataArr) {
                BYcitizenModel *topCarouselModel = [BYcitizenModel mj_objectWithKeyValues:dic];
                [dataArrM addObject:topCarouselModel];
            }
            self.hotDataArr = dataArrM.copy;
            [ws.mainTableView reloadData];
        } fail:^(NSError * _Nonnull error) {
        } showHUD:YES];
    }else{
        [BYNetworking requestGetOrPostWithType:GET url:LJURL_Vitizentopic_list params:dict success:^(NSInteger code, NSString * _Nonnull msg, id  _Nonnull data) {//暂废
            NSDictionary *dict = [data objectForKey:@"data"];
            NSArray *dataArr = dict[@"paginator"][@"records"];
            NSMutableArray *dataArrM = [NSMutableArray arrayWithCapacity:dataArr.count];
            for (NSDictionary *dic in dataArr) {
                BYcitizenModel *topCarouselModel = [BYcitizenModel mj_objectWithKeyValues:dic];
                [dataArrM addObject:topCarouselModel];
            }
            ws.topicListDataArr = dataArrM.copy;
            [ws.mainTableView reloadData];
        } fail:^(NSError * _Nonnull error) {
        } showHUD:YES];
    }
}
- (void)getCarouselIcons:(NSString *)numStr{//请求轮播图
    BY_kWeakSelf(ws);
    [BYNetworking requestGetOrPostWithType:GET url:LJURL_HomeTop_carousel params:@{@"size": BYSafeStr(numStr)} success:^(NSInteger code, NSString * _Nonnull msg, id  _Nonnull data) {
        NSArray *dataArr = [data objectForKey:@"data"];
        NSMutableArray *dataArrM = [NSMutableArray arrayWithCapacity:dataArr.count];
        for (NSDictionary *dic in dataArr) {
            BYHomeTopCarouselModel *topCarouselModel = [BYHomeTopCarouselModel mj_objectWithKeyValues:dic];
            [dataArrM addObject:topCarouselModel];
        }
        ws.topCarDataArr = dataArrM.copy;
        [self.mainTableView reloadData];
    } fail:^(NSError * _Nonnull error) {
    } showHUD:YES];
}


@end
